package com.keyue.controller;

import com.keyue.common.annotation.AnonymousAccess;
import com.keyue.common.constant.ServerResult;
import com.keyue.common.jsr303.OperateGroup;
import com.keyue.domain.vo.EquipmentInfoQueryVO;
import com.keyue.domain.vo.EquipmentInfoVO;
import com.keyue.service.AddressInfoService;
import com.keyue.service.EquipmentInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 设备信息(EquipmentInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-04 15:20:03
 */
@RestController
@RequestMapping("/keyue/admin/equipment")
public class EquipmentInfoController {
    /**
     * 服务对象
     */
    @Resource
    private EquipmentInfoService equipmentInfoService;

    /**
     * 分页查询
     *
     * @param equipmentInfoQueryVO 查询条件
     * @return 查询结果
     */
    @AnonymousAccess
    @PostMapping("/list_by_page")
    public ServerResult listByPage(@RequestBody @Validated({OperateGroup.List.class}) EquipmentInfoQueryVO equipmentInfoQueryVO) {
        return equipmentInfoService.listByPage(equipmentInfoQueryVO);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param equipmentInfoQueryVO 查询条件
     * @return 单条数据
     */
    @AnonymousAccess
    @PostMapping("/query_by_id")
    public ServerResult queryById(@RequestBody EquipmentInfoQueryVO equipmentInfoQueryVO) {
        return equipmentInfoService.queryById(equipmentInfoQueryVO);
    }

    /**
     * 新增数据
     *
     * @param equipmentInfoVO 数据VO
     * @return 新增结果
     */
    @AnonymousAccess
    @PostMapping("/add")
    public ServerResult add(@RequestBody EquipmentInfoVO equipmentInfoVO) {
        return equipmentInfoService.add(equipmentInfoVO);
    }

    /**
     * 编辑数据
     *
     * @param equipmentInfoVO 数据VO
     * @return 编辑结果
     */
    @AnonymousAccess
    @PostMapping("/edit")
    public ServerResult edit(@RequestBody EquipmentInfoVO equipmentInfoVO) {
        return equipmentInfoService.edit(equipmentInfoVO);
    }

    /**
     * 删除数据
     *
     * @param equipmentInfoQueryVO 查询条件
     * @return 删除是否成功
     */
    @AnonymousAccess
    @PostMapping("/delete_by_id")
    public ServerResult deleteById(@RequestBody EquipmentInfoQueryVO equipmentInfoQueryVO) {
        return equipmentInfoService.deleteById(equipmentInfoQueryVO);
    }

}

